package com.world.rickcloudendpoint.service.net.process;

import com.world.rickcloudendpoint.logic.net.NetMessageTcpDispatchLogic;
import com.world.rickcloudendpoint.message.AbstractNetMessage;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * @description: 默认不启用worker线程
 * @author: jlsong
 * @date: 2021/12/23 23:46:25
 * @version: 1.0
 */
@Log4j2
@Component
public class TcpMessageExecutorProcessor implements ITcpMessageProcessor {

    final NetMessageTcpDispatchLogic netMessageTcpDispatchLogic;

    public TcpMessageExecutorProcessor(NetMessageTcpDispatchLogic netMessageTcpDispatchLogic) {
        this.netMessageTcpDispatchLogic = netMessageTcpDispatchLogic;
    }

    @Override
    public void directPutTcpMessage(AbstractNetMessage msg) {
        try {
            netMessageTcpDispatchLogic.dispatchTcpMessage(msg, this);
        } catch (Exception e) {
            log.error("Dispatch message failed,the reason is {} ", e.getMessage(), e);
        }
    }
}
